package com.itpan.Controller;

import com.itpan.Entity.StatsByPrice;
import com.itpan.Entity.StatsByT;
import com.itpan.Service.*;
import com.itpan.common.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Collections;
import java.util.List;

@RestController
@RequestMapping("/stats")
public class StatsConrtoller {
    @Autowired
    private StatsService statsService;

    @Autowired
    private PurchaseOrderDetailService purchaseOrderDetailService;

    @Autowired
    private PurchaseOrderService purchaseOrderService;


    @Autowired
    private EmployeeService employeeService;


    @ApiOperation(value = "统计价格统计区间采购商品数")
    @GetMapping("/getbyprice")
    public R<List<StatsByPrice>> getbyprice(){
        List<StatsByPrice> statsByPrices = statsService.countbyPrice();
        return R.success(statsByPrices);
    }

    @ApiOperation(value = "统计价格统计区间采购商品数")
    @GetMapping("/getbyprice1")
    public List<StatsByPrice> getbyprice1(){
        List<StatsByPrice> statsByPrices = statsService.countbyPrice();
        return statsByPrices;
    }


    @ApiOperation(value = "统计合作供应商次数前十")
    @GetMapping("/getbycustomer")
    public R<List<StatsByT>> getbyCustomer(){
        List<StatsByT> statsByTS = statsService.countBysupplier();
        return R.success(statsByTS);
    }





    @GetMapping("/gettotalofprice")
    @ApiOperation(value = "统计员工的采购总额排名")
    public R<List<StatsByT>> getcounttotalToEmloyee(){
        List<StatsByT> list = purchaseOrderService.getSumPriceOfEveryEmployee();
        return R.success(list);
    }

    @GetMapping("/gettotaltimesofemployee")
    @ApiOperation(value = "统计采购次数最多的员工  姓名和和采购次数")
    public R<List<StatsByT>> getcounttotalTimesOfEmployee(){
        List<StatsByT> list =purchaseOrderService.getcounttimesofEmployee();
        return R.success(list);
    }


    @ApiOperation(value = "统计商品采购数量")
    @GetMapping("/gettotalofproduct")
public R<List<StatsByT>> getsumOfQuantityToproduct(){
    List<StatsByT> list = purchaseOrderDetailService.getSumOfQuantityToproduct();
    return R.success(list);
}

@GetMapping("/getnumbercountbyOrder")
@ApiOperation("采购主表中详细表的数量排行")
public R<List<StatsByT>> getNumberCountbyOrder(){
        List<StatsByT> list= purchaseOrderDetailService.getnumberCountoforder();
        return R.success(list);
}


@GetMapping("/getmaxsalaryemployee")
    @ApiOperation(value = "统计工资排名前十的员工排名")
    public R<List<StatsByT>> getmaxsalaryemployee(){
        List<StatsByT> list=employeeService.gettopofsalary();
        return R.success(list);
}

@GetMapping("/gettotalof7")
    @ApiOperation(value = "统计近七天的采购总额")
    public R<List<StatsByT>> gettotalof7(){
        List<StatsByT> list=purchaseOrderService.gettotalof7();
        return R.success(list);
}


@GetMapping("/getlevelofemployee")
    @ApiOperation(value = "统计员工的工资区间")
    public R<List<StatsByT>> getlevelofemployee(){
        return R.success(employeeService.getlevelofEmployee());
}


@GetMapping("/getavgpricebyproduct")
    @ApiOperation("统计采购商品平均价钱")
    public R<List<StatsByT>> getavgpricebyproduct(){
    List<StatsByT> list = purchaseOrderDetailService.getavgpricebyproduct();
    return R.success(list);
}


}
